import logging

from selenium.webdriver.common.by import By

from utils.base_aolai import BaseObject


class MyHomeObject(BaseObject):
    def __init__(self):
        super().__init__()
        self.myNme = (By.ID, 'com.yunmall.lc:id/tv_user_nikename')
        self.set_btu = (By.ID, 'com.yunmall.lc:id/ymtitlebar_left_btn_image')

    def findMYname(self):
        return self.search_ele(self.myNme)

    def findSet_btu(self):
        return self.search_ele(self.set_btu)


class MyHomeHandle:
    def __init__(self):
        self.mo = MyHomeObject()

    def getName(self):
        name = self.mo.findMYname().text
        logging.info("用户名:{}".format(name))
        return name

    def set_btu(self):
        logging.info("点击设置按钮")
        self.mo.findSet_btu().click()


class MyHomeTask:
    logging.info("个人中心")
    mh = MyHomeHandle()

    @classmethod
    def myName(cls):
        # if cls.mh.getName() == "a-kabi":
        #     print("登陆成功，用户名：{}".format(cls.mh.getName()))
        return cls.mh.getName()

    @classmethod
    def intoSet(cls):
        cls.mh.set_btu()
